<template>
  <div>
    <van-search v-model="searchText" placeholder="请输入队伍名称" @search="getList" />
    <!-- <van-button type="primary" @click="joinTeam">创建队伍</van-button> -->
    <TeamCardList :teamList="teamList" @success="getList()" />
  </div>
</template>

<script setup lang="ts">
import { onMounted, ref, reactive } from 'vue'
import { useRouter } from 'vue-router';
import TeamCardList from '@/components/TeamCardList/index.vue'
import { getTeamByJoin } from '@/api/team/index'
import type { TeamType } from '@/modules/team';
import { useUserStore } from '@/stores/user';

const router = useRouter()
const teamList = ref<TeamType[]>([])
const searchText = ref('')
const userStore  = useUserStore()
// const pageParams = reactive({
//   pageNum: 1,
//   pageSize: 10,
// })
// const joinTeam = () => {
//   router.push({ path: '/team/addTeam' })
// }
const getList = async () => {
  const query = {
    searchText: searchText.value,
  }
  await getTeamByJoin(query).then(res => {
    if (res.code === 200) {
      teamList.value = res.data
    } else {
      teamList.value = []
    }
  })
}

onMounted(() => {
  getList()
})
</script>
